#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    auto compare = [](int a, int b)
    { return a > b; };
    map<int, int, decltype(compare)> yiqi(compare);
    int res = 0;
    for (int i = 0; i < n; ++i)
    {
        int a, b;
        cin >> a >> b;
        yiqi.emplace(make_pair(a, b));
    }
    for (auto m : yiqi)
    {
        if (k == 0)
            break;
        res += m.first;
        k--;
    }
    cout << res << endl;
}